package Demo2;

import jdk.swing.interop.SwingInterOpUtils;

public class EnumDemo {
    public static void main(String[] args) {
        //String name()获取枚举型的名称
        String spring = Season.SPRING.name();
        System.out.println(spring);
        System.out.println("=============");
        //int ordinal() 返回枚举项在枚举类中索引值
        int index = Season.SPRING.ordinal();
        System.out.println(index);
        System.out.println("=============");
        //int compareTo(E o)比较2个枚举项，返回索引值差值
        int i = Season.SPRING.compareTo(Season.WINTER);
        System.out.println(i);
        System.out.println("=============");
        //返回枚举常量名称  打印名称，而不是地址值
        String s = Season.SPRING.toString();
        System.out.println(s);
        System.out.println("=============");
        //获取指定枚举类中 指定的枚举项名称的值
        Season winter = Season.valueOf(Season.class, "WINTER");
        System.out.println(winter);
        System.out.println("=============");
        //values() 获得所有枚举项
        Season[] values = Season.values();
        for (Season value : values) {
            System.out.println(value);
        }
    }
}
